<?php

require_once 'SmartL/Application/Plugin/Abstract.php';
require_once 'Zend/Registry.php';

class Demo_Plugin extends SmartL_Application_Plugin_Abstract
{	
	public function preInitModule($moduleName)
	{
		if ( $moduleName == "Admin" ) {
			Zend_Registry::set('shopLanguages',SmartL_Application::getInstance()->getSupportedLanguages());
			Zend_Registry::set('shopDefaultLanguage',SmartL_Application::getInstance()->getDefaultLanguage());
		}
		return true;
	}
	
	public function preAuthenticateUser()
	{
	    $request = Zend_Controller_Front::getInstance()->getRequest();
	    $auth = Zend_Auth::getInstance();
        require_once 'Zend/Auth/Storage/Session.php';
        
        if ($request->getModuleName() == "Admin") {
            $auth->setStorage(new Zend_Auth_Storage_Session('Auth_Admin'));
        }
        else {
            $auth->setStorage(new Zend_Auth_Storage_Session('Auth_Shop'));
        }
	}
}